﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Macds.Core.XML
{
    public class ClassSchema
    {
        public ClassSchema()
        {
            Properties = new List<PropertySchema>();
        }

        public string Name { get; set; }
        public List<PropertySchema> Properties { get; set; }

        public bool HasProperties
        {
            get
            {
                return Properties.Count > 0 ? true : false;
            }
        }

        public bool PropertyExists(string name)
        {
            if (Properties.Count == 0)
                return false;

            if (Properties.FirstOrDefault(p => p.Name.Trim().ToLower() == name.Trim().ToLower()) != null)
                return true;

            return false;
        }

        public PropertySchema GetProperty(string name)
        {
            return Properties.FirstOrDefault(p => p.Name.Trim().ToLower() == name.Trim().ToLower());
        }
    }
}
